package com.bw.car.net

import androidx.lifecycle.MutableLiveData
import com.bw.car.entity.AddCarParam
import com.bw.car.entity.PackPayEntity
import com.bw.car.entity.PayParam
import com.bw.common.vm.BaseViewModel
import com.bw.http.utils.zgr.OkHttpClientManager

class CarViewModel:BaseViewModel() {
    val packPaySuccess by lazy { MutableLiveData<List<PackPayEntity>>() }

    val addCarSuccess by lazy { MutableLiveData<AddCarParam>() }

    val paySuccess by lazy { MutableLiveData<PayParam>() }

    val apiService:ApiService = OkHttpClientManager.retrofitInstance.create(ApiService::class.java)
    fun getPackPay() {
        executeNetwork(
            { apiService.getPackPay() },
            packPaySuccess::postValue
        )
    }

    fun addCar(body:AddCarParam){
        executeNetwork(
            {
                apiService.addCar(body)
            },
            addCarSuccess::postValue
        )
    }

    fun pay(body:PayParam){
        executeNetwork(
            {
                apiService.pay(body)
            },
            paySuccess::postValue
        )
    }

}